Compressing Still Images
The standard dialog component provides three functions you may use to compress a still image. These functions differ based on how the image is stored:
SCCompressImage
works with pixel maps;
SCCompressPicture
compresses a picture that is stored in a handle; and
SCCompressPictureFile
works with pictures stored in files.
All of these functions use the current compression settings. See
"Displaying the Standard Image-Compression Dialog Box,"
for detailed information about establishing these current settings.
If there are no default settings, each of these functions could potentially display the dialog box for single-frame compression operations shown in
Figure 1
.
SCCompressImage
The
SCCompressImage
function compresses an image that is stored in a pixel map.
pascal ComponentResult SCCompressImage (ComponentInstance ci,
PixMapHandle src,
const Rect *srcRect,
ImageDescriptionHandle *desc,
Handle *data);
-
ci
-
Identifies your application's connection to a standard image-compression dialog component.
-
src
-
Contains a handle to the pixel map to be compressed.
-
srcRect
-
Contains a pointer to a portion of the pixel map to compress. This rectangle must be in the pixel map's coordinate system. If you want to compress the entire pixel map, set this parameter to
nil
.
-
desc
-
Contains a pointer to an image description handle. The standard dialog component creates an image description structure when it compresses the image, and returns a handle to that structure in the field referred to by this parameter. The component sizes that handle appropriately. Your application is responsible for disposing of that handle when you are done with it.
-
data
-
Contains a pointer to a handle. The standard dialog component returns a handle to the compressed image data in the field referred to by this parameter. The component sizes that handle appropriately. Your application is responsible for disposing of that handle when you are done with it.
RESULT CODES
scUserCancelled
|
1
|
Dialog box canceled--user clicked Cancel
|
Image Compression Manager errors (from
FCompressImage
function)
SCCompressPicture
The
SCCompressPicture
function compresses a picture that is stored in a handle.
pascal ComponentResult SCCompressPicture (ComponentInstance ci,
PicHandle srcPicture,
PicHandle dstPicture);
-
ci
-
Identifies your application's connection to a standard image-compression dialog component.
-
srcPicture
-
Contains a handle to the picture to be compressed.
-
dstPicture
-
Contains a handle to the compressed picture. The standard dialog component resizes this handle to accommodate the compressed picture. Your application is responsible for creating and disposing of this handle when you are done with it.
RESULT CODES
scUserCancelled
|
1
|
Dialog box canceled--user clicked Cancel
|
Image Compression Manager errors (from
FCompressPicture
function)
SCCompressPictureFile
The
SCCompressPictureFile
function compresses a picture that is stored in a file.
pascal ComponentResult SCCompressPictureFile
(ComponentInstance ci,
short srcRefNum, short dstRefNum);
-
ci
-
Identifies your application's connection to a standard image-compression dialog component.
-
srcRefNum
-
Contains a reference to the file to be compressed.
-
dstRefNum
-
Contains a reference to the file that is to receive the compressed data. This may be the same as the source file. The standard dialog component places the compressed image data into the file identified by this reference. Your application is responsible for this file after the compression operation.
RESULT CODES
scUserCancelled
|
1
|
Dialog box canceled--user clicked Cancel
|
Image Compression Manager errors (from
FCompressPictureFile
function)
© 1997 Apple Computer, Inc.Previous | Chapter Top | Chapter Contents | Next